<template>
  <div class="login-page">
    <!-- 导航栏 -->
    <!-- <van-nav-bar title="账号登录" /> -->
    <!-- 登录表单 -->
    <van-nav-bar title="账号注册" left-arrow @click-left="onClickLeft" />
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        label="请输入账号"
        placeholder="请输入账号"
        :rules="[{ required: true, message: '请输入账号' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="请输入密码"
        placeholder="请输入密码"
        :rules="[{ required: true, message: '请输入密码' }]"
      />
      <div style="margin: 16px">
        <van-button block type="info" native-type="submit" class="yanse"
          >注册</van-button
        >
      </div>
    </van-form>
    <!-- 路由跳转 -->

    <router-link class="link" to="/login">去登录 </router-link>
  </div>
</template>

<script>
import { register } from '@/api/user.js'

export default {
  name: 'register-page',
  data() {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    async onSubmit(values) {
      console.log('submit', values)

      const data = await register(values)
      this.$toast.success('注册成功')
      console.log(data)
    }
  }
}
</script>

<style lang="less" scoped>
.yanse {
  background-color: #1cb676;
  border: #1cb676;
}
.zh {
  background-color: #1cb676;
  color: aliceblue !important;
}
.link {
  display: block;
  margin: 4px auto;
  text-align: center;
}
::v-deep .van-nav-bar__title {
  color: aliceblue;
  background-color: #1cb676;
}
::v-deep .van-nav-bar__content {
  color: aliceblue;
  background-color: #1cb676;
}
::v-deep .van-nav-bar__left {
  color: aliceblue;
}
</style>
